﻿using System;
using System.Globalization;
using DotLiquid;
using System.IO;
using System.Collections.Generic;

namespace Framework
{
    public class TemplateTag
    {
        internal TemplateTag()
        {

        }
        public class Rd : Tag //随机数
        {
            int _max;
            public override void Initialize(string tagName, string markup, List<string> tokens)
            {
                base.Initialize(tagName, markup, tokens);
                _max = Convert.ToInt32(markup);
            }
            public override void Render(Context context, TextWriter textWriter)
            {
                textWriter.Write(new Random().Next(_max).ToString(CultureInfo.InvariantCulture));
            }
        }

        public class Scale : Block//概率出现
        {
            int _max;
            public override void Initialize(string tagName, string markup, List<string> tokens)
            {
                base.Initialize(tagName, markup, tokens);
                _max = Convert.ToInt32(markup);
            }
            public override void Render(Context context, TextWriter textWriter)
            {
                if (new Random().Next(_max) == 0)
                    base.Render(context, textWriter);
            }
        }

    }

}
